<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../Include/conn.asp" -->
<!--#include file="../Include/config.asp" -->
<script type="text/javascript" src="<%=dir%>js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="<%=dir%>js/layer.js"></script>
<style>
*{font-size:13px;font-family:"Microsoft YaHei","HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue";}
a{text-decoration: none;color:#666666;}
a:hover{color:#f60}
.buy_tab{width:100%;border-collapse:collapse;}
#buybox{border-bottom:1px dotted #CCCCCC}
#total{font-size:24px;font-weight:bold;color:#FF0000}
.buy_tab tr th{font-size:15px;text-align:left;line-height:30px;color:#333333}
.buy_tab .price{ font-size:16px; color: #F30}
.min,.add{border:none;background-color:#FFFFFF;font-size:14px;cursor:pointer}
.btn-u{border:none;background-color:#f60;padding:8px 15px;color:#FFFFFF;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;cursor:pointer;}
.btn-u:hover{background-color:#FF9900}
.right{float:right}
</style>
<%
	act =Request.QueryString("act")
	cid =Request.QueryString("cid")
	allcid = Request.Cookies("productlist")
	If Request.Cookies("productlist") = "" Then		'若id为空，则说明用户没有购物
		allcid = 0
	End If
	
	If act ="del" Then	 '删除购物车中的某一件商品
		aProducts = Split(allcid,",")
		delid = cstr(trim(cid))
		For i = 0 To UBound(aProducts)    '循环所有商品ID
			If Trim(aProducts(i)) <> delid Then
				'不等于被删除的ID时则保存进新的列表中
				sNewProducts = sNewProducts & "," & aProducts(i)
			End If
		Next
		Response.Cookies("productlist") = Mid(sNewProducts,2)
		  If Request.Cookies("productlist") = "" Then
			allcid = 0
		  Else
			allcid = Request.Cookies("productlist")
		  End If
	End If
	If allcid <> 0 and allcid <> "" Then
		Set Rs = Server.CreateObject("adodb.recordset")
		Sql = "Select * From [content] Where Cid In ("&allcid&") Order By Cid"		'这里替换成实际的商品数据库及字段
		Rs.Open Sql,Conn,1,1
 %>	
 <form name="form" action="?act=add" method="post" id="buy_form">
 <table width="100%" border="1" cellpadding="6" cellspacing="0" bordercolor="#EDEDED" class="buy_tab" id="buy_tab">
 <tr>
 <th colspan="5">第一步：确认产品信息：<font>(修改选购数量或清除该记录！)</font></th>
 </tr>
 <tr>
     <td colspan="2">产品信息</td>
     <td width="80"  align="center" valign="middle">价格</td>
     <td width="100"  align="center" valign="middle">数量</td>
     <td width="40"  align="center" valign="middle">清除</td>
 </tr>		 
<% Do While Not Rs.Eof%>
	<tr id="buybox">
	<td width="70"><img src="<%=Rs("img")%>" width="90" height="60" /></td>
	<td><a href="/Show/?Cid=<%=Rs("Cid")%>" title="<%=Rs("title")%>" target="_blank"><%=Rs("title")%></a></td>
	<td align="center" valign="middle"><strike style="color:#666666"><%=lz_money(Rs("yrmb"))%></strike><br/><span class="price"><%=lz_money(Rs("xrmb"))%></span></td>
	<td align="center" valign="middle"> 
	<input class="min" name="" type="button" value="-"  style="background:#DDD"/> 
	<input class="text_box" name="num" type="text" value="1" size="2" style="text-align:center"/> 
	<input class="add" name="" type="button" value="+" style="background:#DDD"/>
	</td>
    <input name="title" type="hidden" value="<%=Rs("title")%>"/>
    <input name="cid" type="hidden" value="<%=Rs("cid")%>"/>
    <input name="xrmb" type="hidden" value="<%=Rs("xrmb")%>"/>
	<td align="center" valign="middle">
	<input name="pid" value="<%=Rs("Cid")%>" type="hidden" size="50"/><input name="money" value="<%=lz_money(Rs("xrmb"))%>" type="hidden" /><a href="?Cid=<%=Rs("Cid")%>&act=del"><font color="#FF0000" size="4" style="font-weight:bold; font-size:22px;">×</font></a>
	</td>
	</tr>
	<%
	Rs.Movenext
	Loop
	Rs.Close:Set Rs = Nothing%>
		<tr>
		<th colspan="5">第二步：填写收货信息：</th>
		</tr>
		<tr>
		<td colspan="5">
		<p>联 系 人 ：<input name="name" type="text" value="<%=u_zsname%>" size="15"/> *</p>
		<p>联系电话：<input name="tel" type="text" value="<%= u_tel %>" size="20"/> *</p>
		<p>详细地址：<input name="add" type="text" value="<%= u_gsadd %>" size="50"/> *</p>
		<p>留言内容：<textarea name="content" cols="" rows="" style="width:320px; height:100px"></textarea></p>
		<p>总额：<label id="total"></label> 元<input id="rmb" name="rmb" value="" type="hidden"/><input value="确认无误 提交" class="btn-u right" type="submit"/></p>
</td></tr></table></form>
	<%Else%>
		购物车内没有商品，请选择需订购的商品。
	<%End if

if Request.QueryString("act")="add" then
	num=Request.Form("num")
	xrmb=Request.Form("xrmb")
	cid=Request.Form("cid")
	title=Request.Form("title")
	OrderNo=getTime&getStrRandNumber(1000,9999)
	If Request.Form("name") = "" Then
		response.Write("<script language=javascript>alert('姓名不能为空!');history.go(-1)</script>")
		response.End()
	End If
	If Request.Form("tel") = "" Then
		response.Write("<script language=javascript>alert('电话不能为空!');history.go(-1)</script>")
		response.End()
	End If
	If Request.Form("add") = "" Then
		response.Write("<script language=javascript>alert('地址不能为空!');history.go(-1)</script>")
		response.End()
	End If
	set rs=server.createobject("adodb.recordset")
	sql="select * from [orders]"
	rs.open sql,conn,1,3
	rs.addnew
	rs("OrderNo")=OrderNo
	rs("title")=replace(title,", ","|")
	rs("cid")=replace(cid,", ","|")
	rs("xrmb")=replace(xrmb,", ","|")
	rs("number")=replace(num,", ","|")
	rs("rmb")=Request.Form("rmb")
	rs("userid")=session("username")
	rs("qq")=qq
	rs("name")=Request.Form("name")
	rs("tel")=Request.Form("tel")
	rs("address")=Request.Form("add")
	rs("sm")=Request.Form("content")
	rs.update
	rs.close
	set rs=nothing
	Response.Cookies("productlist")=""
	response.clear
	response.Write" 恭喜您,您的订单编号："&OrderNo&"提交成功。请到会员中心付款"
end if
%>